/**
 * 获取当前时间戳（毫秒）
 */
getTimestamp = () => {
	return Date.now()
}

getWorldTime = () => {
	return new Date()
}

addZero = (text) => {
	if (text < 10) {
		return '0' + text
	}
	return text
}

getNowDate = () => {
	let date = new Date();
	let year = date.getFullYear();
	let month = addZero(date.getMonth() + 1);
	let day = addZero(date.getDate());
	return year + '-' + month + '-' + day;
}

getNowTime = () => {
	let date = new Date();
	let year = date.getFullYear();
	let month = addZero(date.getMonth() + 1);
	let day = addZero(date.getDate());

	var h = date.getHours();
	var m = date.getMinutes();
	var s = date.getSeconds();
	return year + '-' + month + '-' + day + '  ' + h + ':' + m + ':' + s;
}

getWeekDay = () => {
	let date = new Date();
	return date.getDay();
}

getWeekDayName = (text) => {
	let res = '一';
	if (text == 1) {
		res = '一';
	} else if (text == 2) {
		res = '二';
	} else if (text == 3) {
		res = '三';
	} else if (text == 4) {
		res = '四';
	} else if (text == 5) {
		res = '五';
	} else if (text == 6) {
		res = '六';
	} else if (text == 7) {
		res = '日';
	}
	return '星期 ' + res
}

getLongTime = (time) => {
	var date = new Date(time);
	return date.getTime();
}

function timestampToTime(timestamp) {
	// 时间戳为10位需*1000，时间戳为13位不需乘1000
	var date = new Date(timestamp * 1000);
	var Y = date.getFullYear() + "-";
	var M =
		(date.getMonth() + 1 < 10 ?
			"0" + (date.getMonth() + 1) :
			date.getMonth() + 1) + "-";
	var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
	var h = date.getHours() + ":";
	var m = date.getMinutes() + ":";
	var s = date.getSeconds();
	return Y + M + D + h + m + s;
}
